﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class BillStream : IAccessible<T_BillStream, BillStream>, ILogicEntity<T_BillStream, BillStream>
    {
        #region Fileds
        public int Id { get; set; }
        public string Own { get; set; }
        public int ManuscriptId { get; set; }

        /// <summary>
        /// 支付账串
        /// </summary>
        public string DocStream { get; set; }
        /// <summary>
        /// 支付交易号
        /// </summary>
        public string Txid { get; set; }

        /// <summary>
        /// 支付总额
        /// </summary>
        public int TotalPay { get; set; }
        /// <summary>
        /// 支付状态
        /// 0:支付发起
        /// 1:支付完成
        /// </summary>
        public int Status { get; set; }

        public DateTime CreateTime { get; set; }
        
        public DateTime CompleteTime { get; set; }

        /// <summary>
        /// 支付发起序列
        /// </summary>
        public string PayToStream { get; set; }

        /// <summary>
        /// 支付返回序列
        /// </summary>
        public string PayBackStream { get; set; }

        public string Message { get; set; }

        #endregion


        protected override void Covariant(T_BillStream model)
        {
            if (model != null)
            {
                this.CompleteTime = model.CompleteTime;
                this.CreateTime = model.CreateTime;
                this.DocStream = model.DocStream;
                this.Id = model.Id;
                this.ManuscriptId = model.ManuscriptId;
                this.Message = model.Message;
                this.PayBackStream = model.PayBackStream;
                this.PayToStream = model.PayToStream;
                this.Status = model.Status;
                this.TotalPay = model.TotalPay;
                this.Txid = model.Txid;
                this.Own = model.Own;
            }
        }

        protected override T_BillStream Inverter(BillStream model)
        {
            if (model != null)
            {
                return new T_BillStream()
                {
                    CompleteTime = model.CompleteTime,
                    CreateTime = model.CreateTime,
                    DocStream = model.DocStream,
                    Id = model.Id,
                    ManuscriptId = model.ManuscriptId,
                    Message = model.Message,
                    PayBackStream = model.PayBackStream,
                    PayToStream = model.PayToStream,
                    Status = model.Status,
                    TotalPay = model.TotalPay,
                    Txid = model.Txid,
                    Own=model.Own
                };
            }
            return null;
        }

        public BillStream Set(T_BillStream dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
